From 11b28cbed77502aaa8227c803cb73026aed58580 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 17 Jan 2017 14:53:45 +0000 Subject: [PATCH] make build reproducible by allowing build systems to use a constant date instead of the current one see https://reproducible-builds.org/ for why this is good This call is designed to work with both GNU date and BSD date implementations --- Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index c2b62df16..23b341bdc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -22,7 +22,8 @@ CFG_RELEASE=$(CFG_RELEASE_NUM)-dev CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev endif -CFG_BUILD_DATE = $(shell date +%F) +# allow build systems to use a constant date instead of the current one +CFG_BUILD_DATE = $(shell SOURCE_DATE_EPOCH="$${SOURCE_DATE_EPOCH:-$$(date +%s)}" ; date -u -d "@$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u -r "$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u +%F) ifeq ($(wildcard $(CFG_SRC_DIR)/.git),) CFG_VERSION = $(CFG_RELEASE) (built $(CFG_BUILD_DATE)) -- 2.30.2